home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 25 / CU Amiga Magazine's Super CD-ROM 25 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-08].iso / CUCD / Magazine / C_Tutorial / Part-13 / PatchLib / source / AddPatchNotifyA.c next >
Encoding:
C/C++ Source or Header  |  1997-05-01  |  2.4 KB  |  83 lines

  1. /*
  2. **    patch.library
  3. **
  4. **    Copyright © 1993-1997 by Stefan Fuchs
  5. **        Freely distributable.
  6. */
  7.  
  8. #ifndef _PATCH_INCLUDES_H
  9. #include "patch_includes.h"
  10. #endif
  11.  
  12. /****** patch.library/AddPatchNotifyA ******************************************
  13. *
  14. *   NAME
  15. *        AddPatchNotifyA -- Get messages, if a patch is changed. (V5)
  16. *        AddPatchNotify -- varargs stub for AddPatchNotifyA(). (V5)
  17. *
  18. *   SYNOPSIS
  19. *        Error = AddPatchNotifyA( msgport, taglist )
  20. *        D0                       A0       A1
  21. *
  22. *        ULONG Error AddPatchNotifyA( struct MsgPort *, struct TagItem *);
  23. *
  24. *        Error = AddPatchNotify( msgport, ...)
  25. *
  26. *        ULONG Error AddPatchNotify( struct MsgPort *, ...);
  27. *
  28. *   FUNCTION
  29. *        Patch.library will immediately start sending out PatchNotifyMessages
  30. *        (see patch.h) of PATCHNOTIFY_CLASS to the given message port, if
  31. *        a patch is added, removed or changed.
  32. *
  33. *        pnm_Code contains PATCOD_xxx values to indicate the kind of
  34. *        change. For PATCOD_PatchInstalled and PATCOD_PatchChanged
  35. *        pnm_Object will contain a pointer to the corresponding
  36. *        patch structure.
  37. *
  38. *   INPUTS
  39. *        msgport = pointer to msgport ready to receive messages or
  40. *                  null for no action
  41. *        taglist = pointer to array of tags
  42. *
  43. *   TAGS
  44. *        PATT_Priority (BYTE) - Optional priority for the notification request
  45. *                Normally only the priorities +5, 0, -5 should be used.
  46. *
  47. *   RESULT
  48. *        Error = errorcode as defined in patch.h.
  49. *                PATERR_Ok
  50. *                        Indicates success of the operation.
  51. *                PATERR_OutOfMem
  52. *                        Indicates that there was not enough memory to
  53. *                        complete the operation.
  54. *
  55. *   NOTES
  56. *
  57. *   BUGS
  58. *
  59. *   SEE ALSO
  60. *        RemPatchNotify(), patch.h
  61. *
  62. ******************************************************************************
  63. *
  64. */
  65. ULONG LIBFUNC AddPatchNotifyA( REGA0 struct MsgPort *msgport GNUC_REGA0, REGA1 struct TagItem *taglist GNUC_REGA1)
  66. {
  67. struct Node *pointer;
  68. LONG pri;
  69.     if( msgport == NULL) return(NULL);
  70.  
  71.     if( FindPatchNotify(msgport)) return(PATERR_Ok);
  72.  
  73.     pri = GetTagData(PATT_Priority, 0L, taglist);
  74.     pointer = ACreateMyListNodePri( &(PatchBase->PB_NotifyListHeader), sizeof(struct Node), pri);
  75.  
  76.     if(pointer)
  77.     {
  78.         pointer->ln_Name = (char *)msgport;
  79.         return(PATERR_Ok);
  80.     }
  81.     else
  82.         return(PATERR_OutOfMem);
  83. }